<%@page import="java.sql.*"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ include file="common.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link href="Default.css" rel="stylesheet" type="text/css">
       <title>Thêm sản phẩm</title>
    </head>
<style type="text/css">

#a {
	color: blue;
	background-color: #FF9A00;
	display: block;
	text-decoration: none;
	font-family: cursive;
}

#a:HOVER {
	color: #FFFFFF;
	background-color: #FF4700;
	text-decoration: none;
	display: block;
	font-family: cursive;
}

#a:ACTIVE {
	background-color: #FF4700;
	text-decoration: none;
	display: block;
	font-family: cursive;
}
#a:LANG {
	color: #FFFFFF;
	background-color: #FF4700;
	text-decoration: none;
	display: block;
	font-family: cursive;
}

</style>
</head>
<body>
<p align=center><font size=10>Chỉnh sửa thông tin sản phẩm</font></p>
<%
	//String userid=getVal((String)session.getValue("userid"),"");
	//if(userid.equals("")|| userid.equals("0") || userid.equals("-1")|| userid.equals("-2")) response.sendRedirect("admin.jsp");
%>
<%
	Class.forName("com.mysql.jdbc.Driver");
	Connection con = null;
	Statement smt = null;
	ResultSet rst = null;
	String str = null;
	String ID = request.getParameter("id");
	System.out.println("ID");
	try {
		String username = "root";
		String password = "root";
		String url = "jdbc:mysql://127.0.0.1:3306/laptop";
		con = DriverManager.getConnection(url, username, password);
		System.out.println("Da ket noi CSDL");
		smt = con.createStatement();
		rst = smt.executeQuery("select * from product where ID='"+ID+"'");
		rst.next();
		out.println("<form action=sqledit.jsp method=POST>");
		out.println("<table width=1024 align=center>");
		out.println("<tr><td width=1024 align='center' colspan=2><a id='a' href='productmanager.jsp'>Quay về trang quản lí</a><br><br></td></tr>");
		out.println("<tr><td width=30% align=right>Tên máy: </td>");
		out.println("<td width=70% align=left><input name=name type=text size=50 value='"+rst.getString(2)+"'></td></tr>");
		out.println("<tr><td width=30% align=right>Hãng sản xuất: </td>");
		out.println("<td width=70% align=left>");
		out.println("<select name=provider>");
		out.println("<option value='Sony Ericsson'>Sony Ericsson</option>");
		out.println("<option value='Nokia'>Nokia</option>");
		out.println("<option value='Apple'>Apple</option>");
		out.println("<option value='Samsung'>Samsung</option>");
		out.println("<option value='Motorola'>Motorola</option>");
		out.println("</select></td></tr>");
		out.println("<tr><td width=30% align=right>Giá: </td>");
		out.println("<td width=70% align=left><input name=price type=text size=50 value='"+rst.getString(4)+"'></td></tr>");
		out.println("<tr><td width=30% align=right valign=top>Chi tiết cấu hình: </td>");
		out.println("<td width=70% align=left><textarea name=detail rows=10 cols=20>"+rst.getString("detail")+"</textarea></td></tr>");
		out.println("<tr><td width=30% align=right>Trạng thái: </td>");
		out.println("<td width=70% align=left><select name=state>");
		out.println("<option value='1'>còn hàng</option>");
		out.println("<option value='0'>hết hàng</option>");
		out.println("</select></td></tr>");
		out.println("<tr><td width=30% ><input type=hidden name=ID value='"+ID+"'</td>");
		out.println("<td width=70% align=right><input type=submit value=Xong></td></tr>");
		out.println("</table>");
		out.println("</form>");
	} catch (Exception ex) {}
	con.close();
	
%>
</body>
</html>